package com.eduction.modules.system.dao;

import com.eduction.common.dbutil.DbHelper;
import com.eduction.modules.system.entity.ApplyFile;
import com.eduction.modules.system.entity.ApplyFileBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

@Repository
public class ApplyFileBaseRepository {

	@Autowired
	private DbHelper dbHelper;
	@Autowired
	private ApplyFileBaseDao applyFileBaseDao;
	
	/**
	 * 查询学校自评表基础信息
	 * @throws SQLException 
	 */
	public ApplyFileBase queryApplyFileBaseBySchoolId(String schoolId) throws SQLException{
		String sql = "SELECT * FROM t_apply_file_base where school_id = ? ";
		return dbHelper.getBean(sql, ApplyFileBase.class, schoolId);
		
	}
	
	/**
	 * 保存该校的自评表
	 */
	public void saveAppplyFileBase(ApplyFileBase a) throws SQLException{
		ApplyFileBase base=queryApplyFileBaseBySchoolId(a.getSchoolId());
		if(base!=null&&base.getId()!=null){
			applyFileBaseDao.delete(base.getId());
		}
		applyFileBaseDao.save(a);
	}


	public void deleteApplyFile(String pId) {
		applyFileBaseDao.delete(pId);
	}
}
